import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  // 数据仓库用来储存数据
  state: {
    counts:1,
    userinfo:{}
  },
  getters: {
  },
  mutations: {
    adds(state){
      state.counts++
    },
    userChange(state,userinfo){
      if(userinfo){
        localStorage.setItem('userinfo',JSON.stringify(userinfo));
        state.userinfo = JSON.parse(localStorage.getItem('userinfo'));
      }else{
        state.userinfo = JSON.parse(localStorage.getItem('userinfo'));
      }
    }
  },
  actions: {
  },
  modules: {
  }
})
